<?php

/**
 * @author Martin Pernica
 * @copyright 2009
 */
$error = 0;
if (empty($_POST['realPath']) || empty($_POST['urlPath']) || empty($_POST['sql_user']) ||
    empty($_POST['sql_pass']) || empty($_POST['sql_db']) || empty($_POST['sql_host'])) {
    echo '<p class="msg warning">Musíte vyplnit všechny pole !</p>';
    echo "\n<a href=\"index.php?p=" . (intval($_GET['p']) - 1) . "\">Zpět</a>";
    $error = $error + 1;
} else {

    if (!VInstallater::TestSqlSetting($_POST['sql_user'], $_POST['sql_pass'], $_POST['sql_db'],
        $_POST['sql_host'])) {
        echo '<p class="msg error">Údaje k MySQL nejsou platné !</p>';
        echo "\n<a href=\"index.php?p=" . (intval($_GET['p']) - 1) . "\">Zpět</a>";
        $error = $error + 1;
    } elseif ((!VInstallater::TestFtpSetting($_POST['ftp_user'], $_POST['ftp_pass'], $_POST['ftp_host'])) || (intval($_POST['ftp_on']) != 0)) {
    	echo '<p class="msg error">Údaje k FTP nejsou platné !</p>';
        echo "\n<a href=\"index.php?p=" . (intval($_GET['p']) - 1) . "\">Zpět</a>";
        $error = $error + 1;
    } else {
        echo '<p class="msg done">Údaje k MySQL jsou platné.</p>';

        $_SESSION['step3'] = true;
        $_SESSION['sample_data'] = intval($_POST['sample_data']);
        $_SESSION['ftp_on'] = intval($_POST['ftp_on']);
        $_SESSION['seo'] = intval($_POST['seo']);

        $_SESSION['realPath'] = $_POST['realPath'];
        $_SESSION['urlPath'] = $_POST['urlPath'];
        $_SESSION['mysql']['host'] = $_POST['sql_host'];
        $_SESSION['mysql']['user'] = $_POST['sql_user'];
        $_SESSION['mysql']['pass'] = $_POST['sql_pass'];
        $_SESSION['mysql']['db'] = $_POST['sql_db'];
        $_SESSION['mysql']['prefix'] = $_POST['sql_prefix'];
        
        $_SESSION['ftp']['host'] = $_POST['ftp_host'];
        $_SESSION['ftp']['user'] = $_POST['ftp_user'];
        $_SESSION['ftp']['pass'] = $_POST['ftp_pass'];

?>
<h2>Účet správce</h2>
<form action="" method="post">
<table>

<tr><td>Přihlašovací jméno:</td><td><input type="text" name="username" id="username" size="50" value="<?php echo
$_SESSION['adminUsername'] ?>" /></td></tr>
<tr><td>Heslo:</td><td><input type="password" name="pass" id="pass" size="50" value="<?php echo
$_SESSION['adminPass'] ?>" /></td></tr>
<tr><td>Znovu heslo:</td><td><input type="password" name="pass2" id="pass2" size="50" value="<?php echo
$_SESSION['adminPass'] ?>" /></td></tr>
<tr><td>E-Mail:</td><td><input type="text" name="email" id="email" size="50" value="<?php echo
$_SESSION['adminEmail'] ?>" /></td></tr>
</table>
</form>
<?php
    }
}
$buttons_left .= VInstallater::PrintButton("cancel");
if ($error == 0) {
    $buttons_right .= VInstallater::PrintButton("right");
} else {
    $buttons_right .= VInstallater::PrintButton("right-inactive");
}


$menu = "<li class=\"done\"><a href=\"index.php?p=1\">  1. Kontrola</a></li>\n
<li class=\"done\"><a href=\"index.php?p=2\">  2. Licence</a></li>\n
<li class=\"done\"><a href=\"index.php?p=3\">  3. Nastavení</a></li>\n
<li class=\"now\"> 4. Účet správce</li>\n
<li> 5. Přehled</li>\n
<li> 6. Instalace</li>\n
<li> 7. Výsledek instalace</li>\n";

?>